package com.waiter.moximoxi.net;

import com.waiter.moximoxi.app.MyApplication;
import com.waiter.moximoxi.constant.Constant;

import java.util.HashMap;
import java.util.Map;

import cn.yhong.aframework.utils.JsonUtils;
import cn.yhong.aframework.utils.SpUtils;

/**
 * 接口工具类
 */
public class APIUtils extends JsonUtils {

    /**
     * 参数封装
     *
     * @return
     */
    public static Map<String, String> getUserTokenMap() {
        Map<String, String> params = new HashMap<>();
        params.put("token", getUserToken());
        return params;
    }

    /**
     * 用户token
     *
     * @return 93c78645-35ed-4c88-b161-ac6793c652ae
     */
    public static String getUserToken() {
        return (String) SpUtils.getData(MyApplication.appContext, Constant.USER_TOKEN, "");
    }

    /**
     * 是否登录
     *
     * @return
     */
    public static boolean isLogin() {
        return (Boolean) SpUtils.getData(MyApplication.appContext, Constant.IS_LOGIN, false);
    }

    /**
     * 用户id
     *
     * @return
     */
    public static String getUserId() {
        return (String) SpUtils.getData(MyApplication.appContext, Constant.USER_ID, "0");
    }

}
